
/**
 * 
 * @param {*} t 
 * @param {*} e   cond_code
 * @returns 
 */
Number.prototype.between = function (t, e) { let i = Math.min.apply(Math, [t, e]), n = Math.max.apply(Math, [t, e]); return this >= i && this <= n }
const WIDGET = {
    CONFIG: {
        md: "012346",
        bg: "1",
        lc: "auto", key: "66ba4d529ea94041b505fb1ccf7ab60a",
        demo: getUrlKey("demo"),
        v: "_1697261276475",
        lg: getUrlKey("lg") || "zh"
    }
}
function getBackground(t, e) {
    return 2 === (t = parseInt(t)) ? {
        backgroundImage: 'url("https://widget-s.qweather.net/img/plugin/190516/bg/h5/darkd.png")',
        backgroundRepeat: "no-repeat",
        backgroundPosition: "center -2.5rem",
        backgroundColor: "#313A44"
    } : 3 === t ? {
        backgroundImage: 'url("https://widget-s.qweather.net/img/plugin/190516/bg/h5/lightd.png")',
        backgroundRepeat: "no-repeat",
        backgroundPosition: "center -2.5rem",
        backgroundColor: "#FAFAFA"
    } : {
        backgroundImage: 'url("https://widget-s.qweather.net/img/plugin/190516/bg/h5/' + e + dayOrNight() + '.png")',
        backgroundRepeat: "no-repeat", backgroundPosition: "0% 0%",
        backgroundColor: codeToColor(e)
    }
}

function dayOrNight() { let t = (new Date).getHours(); return t >= 6 && t <= 18 ? "d" : "n" }

function codeToColor(t) {
    let e = dayOrNight();
    return 503 === (t = parseInt(t)) || 504 === t || 507 === t || 508 === t ? "d" === e ? "#837b6d" : "#27221e" : 502 === t || 511 === t || 512 === t || 513 === t ? "d" === e ? "#9f9c97" : "#24251f" : 500 === t || 501 === t || 509 === t || 510 === t || 514 === t || 515 === t ? "d" === e ? "#4c687e" : "#292933" : t.between(400, 410) || 499 === t ? "d" === e ? "#95aacc" : "#3e437b" : t.between(302, 304) ? "d" === e ? "#132533" : "#010204" : t.between(305, 318) || 300 === t || 301 === t || 399 === t ? "d" === e ? "#1b2326" : "#090c1b" : t.between(101, 103) ? "d" === e ? "#354b76" : "#101925" : 104 === t ? "d" === e ? "#323f4b" : "#101925" : t.between(200, 213) || 100 === t || 999 === t ? "d" === e ? "#3572c6" : "#11132a" : "black"
}

function getUrlKey(t) {
    let e = location.href;
    return decodeURIComponent((new RegExp("[?|&]" + t + "=([^&;]+?)(&|#|;|$)").exec(e) || [, ""])[1].replace(/\+/g, "%20")) || null
}

export { WIDGET, getBackground, dayOrNight, codeToColor, getUrlKey }